import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { StudentStudentProfileEntity } from '../../entity/studentProfile';
import { StudentStudentProfileService } from '../../service/studentProfile';
import { UserInfoEntity } from '../../../user/entity/info';

/**
 * 学生档案控制器
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: StudentStudentProfileEntity,
  service: StudentStudentProfileService,
  insertParam: ctx => {
    return {
      createUserId: ctx.user.id,
    };
  },
  pageQueryOp: {
    keyWordLikeFields: ['a.remark'],
    fieldEq: ['a.studentId'],
    select: ['a.*', 'b.nickName as studentName'],
    join: [
      {
        entity: UserInfoEntity,
        alias: 'b',
        condition: 'a.studentId = b.id',
        type: 'leftJoin',
      },
    ],
  },
})
export class AppStudentStudentProfileController extends BaseController {
  @Inject()
  studentStudentProfileService: StudentStudentProfileService;
}
